<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
   <%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
   <base herf="${pageContext.request.contextPath }/">
      <link rel="stylesheet" type="text/css" href="../css/meteinfo_ui.css" id="metuimodule" data-module="1" />
		<link rel="stylesheet" type="text/css" href="../css/metinfo.css" />
		<script type="text/javascript" src="js/jquery-3.2.1.min.js" ></script>
<title>Insert title here</title>
</head>
<body>
 <form id="frmAddBooking" method='POST' name='myform' action="creatImgCode!update.action"   target='_self'>
                        <input type="hidden" name="sub.subId" value="${subInfo.subId }">
						<table class='feedback_table' style="margin-top: -100px;">
							<tr>
								<td class='text'>姓名:</td>
								<td class='input'><input id="names" maxlength="10" name='sub.subName' value="${subInfo.subName }" type='text' size='30' class='input-text' /><span class='info' id="name">*</span></td>
							</tr>
							<tr>
								<td class='text'>性别:</td>
								<td class='input'>
								   <s:if test="#subInfo.subSex=='男'.toString()">
									<input name='sub.subSex' type='radio' id='para18' value='男' checked='checked' />
									<label for='para18'>男</label> 
									<input name='sub.subSex' type='radio' id='para28' value='女' />
									<label for='para28'>女</label>
									</s:if> 
									<s:else>
									<input name='sub.subSex' type='radio' id='para18' value='男'  />
									<label for='para18'>男</label> 
									<input name='sub.subSex' type='radio' id='para28' value='女' checked='checked' />
									<label for='para28'>女</label>
									</s:else>
									<span class='info' id="sex"></span><span></span></td>
							</tr>
							<tr>
								<td class='text'>车牌:</td>
								<td class='input'><input id="carNum" maxlength="10" name='sub.subLicense_plate' type='text' value="${subInfo.subLicense_plate }" size='30' class='input-text' /><span class='info' id="licensePlateNumber">*</span></td>
							</tr>
							<tr>
								<td class='text'>车型:</td>
								<td>&nbsp;&nbsp;
									<select style="width: 160spx;" class="input" name="sub.subModel">
										<option>小型车</option>
										<option>微型车</option>
										<option>紧凑车型</option>
										<option>CDV车型</option>
										<option>MPV车型</option>
										<option>SUV车型</option>
										<option>三厢车型</option>
										<option>豪华车型</option>
										
									</select>
								</td>
								
							</tr>
							<tr>
								<td class='text'>手机:</td>
								<td class='input'><input id="phones" name="sub.subPhone" maxlength='11' type='text' value="${subInfo.subPhone }" size='30' class='input-text' /><span id="phone" class='info'></span><span></span></td>
							</tr>
							
							<tr>
								<td class='text'>预约时间:</td>
								<td class='input'>
								<input id="time" name="sub.subTime"  type="datetime-local" value="${subInfo.subTime }"  /><span  class='info' id="appointmentTime"></span>
								</td>
							</tr>
							<tr>
								<td class='text'>服务类型:</td>
								<td>&nbsp;&nbsp;
									<select style="width: 160spx;" class="input" name="sub.sunService_type">
										<option>&nbsp;&nbsp;修车</option>
										<option>&nbsp;&nbsp;保养</option>
									</select>
								</td>
								
						</table>
					</form>
	
	<script type="text/javascript">
			$(function(){
				/* layui.use(['form', 'layedit', 'laydate','layer'], function(){
					   var form = layui.form
					  ,layer = layui.layer
					  ,layedit = layui.layedit
					  ,laydate = layui.laydate
					  , $ = layui.$ //jquery对象 */
				$("#btnSubmit").click(function(){
					var name=$("#names").val();
					
					var phone=$("#phones").val();
					var appointmentTime=$("#time").val();
					var code=$("input[name=code]").val();
					var licensePlateNumber=$("#carNum").val();
					//alert(licensePlateNumber)
					var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/; 
					if(name=="" ||name==null){
						$("#name").text("请输入姓名");
						return false; 
					}
					$("#name").text("");
					
					var is= isVehicleNumber(licensePlateNumber);
					if(!is){
						$("#licensePlateNumber").text("请输入正确的车牌号码");
						return false;
					}
					$("#licensePlateNumber").text("");
					if(!myreg.test(phone)) 
					{ 
					   $("#phone").text("请输入有效的手机号码！");
					    return false; 
					}  $("#phone").text("");
					
					if(appointmentTime.length<3){
						//alert("错")
						$("#appointmentTime").text("请选择预约时间");
						return false; 
					}
					$("#appointmentTime").text("");
					
					if(code==""){
						$("#code").text("请输入验证码");
						return false; 
					}
					//可以提交
					var frm = $("#frmAddBooking").serialize();
					$.post("creatImgCode!update.action",frm,function(data){
						
						if(data){
							 window.parent.window.history.go(0);
							 closeThis();
						}
					});
					//return true;
					
				})
				//var ver= ${verification}
			    //alert("sdf")
				//对验证码进行 验证
				$("#code").text("");
				
				  $(".code").keypress(function () { // keypress：输入框每获取一个字符，就触发一次该事件。
					 alert("d")
					 //$("span").text(i++);
			     });
				  
				 
			});
		       //页面加载刷新图片验证码  
			 $("#img").click();  
			//生成图片验证码  
			function changeValidateCode() {  
			    //获取当前的时间作为参数，无具体意义     
			    var timenow = new Date().getTime();  
			    //每次请求需要一个不同的参数，否则可能会返回同样的验证码     
			    //这和浏览器的缓存机制有关系，也可以把页面设置为不缓存，这样就不用这个参数了。     
			    $("#img").src = "creatImgCode.action?d="+Math.random();  
			   /*  $.post("creatImgCode!yz.action",{},function(data){
	            	alert()
	            }) */
			} 
            

			//正则表达式验证车牌号码是否正确
			  function isVehicleNumber(vehicleNumber) {
			      var result = false;
			      if (vehicleNumber.length == 7){
			        var express = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/;
			        result = express.test(vehicleNumber);
			      }
			      return result;
			     
			  }
			 
			//关闭当前窗口
				function closeThis(){
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
					return;
				}
		</script>
<script type="text/javascript" src="layui/layui.all.js" ></script>


</body>
</html>